<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>std::chrono::duration</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/chrono/duration","wgTitle":"cpp/chrono/duration","wgCurRevisionId":64123,"wgArticleId":1533,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/chrono/duration","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_chrono_duration skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::chrono::</span>duration</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../chrono.html" title="cpp/chrono">chrono</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../utility.html" title="cpp/utility">工具库</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../types.html" title="cpp/types">类型支持</a>（基本类型、 RTTI 、类型特性）</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../memory.html" title="cpp/memory">动态内存管理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error">错误处理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility/program.html" title="cpp/utility/program">程序工具</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility/variadic.html" title="cpp/utility/variadic">变参数函数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility/feature_test.html" title="cpp/utility/feature test">库特性测试宏</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../chrono.html" title="cpp/chrono">日期和时间</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility/functional.html" title="cpp/utility/functional">函数对象</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility/format.html" title="cpp/utility/format"> 格式化库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/initializer_list.html" title="cpp/utility/initializer list"><span class="t-lines"><span>initializer_list</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/source_location.html" title="cpp/utility/source location"><span class="t-lines"><span>source_location</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/bitset.html" title="cpp/utility/bitset"><span class="t-lines"><span>bitset</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/hash.html" title="cpp/utility/hash"><span class="t-lines"><span>hash</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/integer_sequence.html" title="cpp/utility/integer sequence"><span class="t-lines"><span>integer_sequence</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 关系运算符 <span class="t-mark-rev t-deprecated-cxx20">(C++20 中弃用)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/rel_ops/operator_cmp.html" title="cpp/utility/rel ops/operator cmp"><span class="t-lines"><span>rel_ops::operator!=</span><span>rel_ops::operator&gt;</span><span>rel_ops::operator&lt;=</span><span>rel_ops::operator&gt;=</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 比较 <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr><tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/three_way_comparable.html" title="cpp/utility/compare/three way comparable"><span class="t-lines"><span>three_way_comparable</span><span>three_way_comparable_with</span></span></a></div></div></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/strong_ordering.html" title="cpp/utility/compare/strong ordering"><span class="t-lines"><span>strong_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/weak_ordering.html" title="cpp/utility/compare/weak ordering"><span class="t-lines"><span>weak_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/partial_ordering.html" title="cpp/utility/compare/partial ordering"><span class="t-lines"><span>partial_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/common_comparison_category.html" title="cpp/utility/compare/common comparison category"><span class="t-lines"><span>common_comparison_category</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/compare_three_way_result.html" title="cpp/utility/compare/compare three way result"><span class="t-lines"><span>compare_three_way_result</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/compare_three_way.html" title="cpp/utility/compare/compare three way"><span class="t-lines"><span>compare_three_way</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/strong_order.html" title="cpp/utility/compare/strong order"><span class="t-lines"><span>strong_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/weak_order.html" title="cpp/utility/compare/weak order"><span class="t-lines"><span>weak_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/partial_order.html" title="cpp/utility/compare/partial order"><span class="t-lines"><span>partial_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/compare_strong_order_fallback.html" title="cpp/utility/compare/compare strong order fallback"><span class="t-lines"><span>compare_strong_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/compare_weak_order_fallback.html" title="cpp/utility/compare/compare weak order fallback"><span class="t-lines"><span>compare_weak_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/compare_partial_order_fallback.html" title="cpp/utility/compare/compare partial order fallback"><span class="t-lines"><span>compare_partial_order_fallback</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/compare/named_comparison_functions.html" title="cpp/utility/compare/named comparison functions"><span class="t-lines"><span>is_eq</span><span>is_neq</span><span>is_lt</span><span>is_lteq</span><span>is_gt</span><span>is_gteq</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 共用词汇类型</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/pair.html" title="cpp/utility/pair"><span class="t-lines"><span>pair</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/tuple.html" title="cpp/utility/tuple"><span class="t-lines"><span>tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/apply.html" title="cpp/utility/apply"><span class="t-lines"><span>apply</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/make_from_tuple.html" title="cpp/utility/make from tuple"><span class="t-lines"><span>make_from_tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/optional.html" title="cpp/utility/optional"><span class="t-lines"><span>optional</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/any.html" title="cpp/utility/any"><span class="t-lines"><span>any</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/variant.html" title="cpp/utility/variant"><span class="t-lines"><span>variant</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> swap 、 forward 与 move</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../algorithm/swap.html" title="cpp/algorithm/swap"><span class="t-lines"><span>swap</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/exchange.html" title="cpp/utility/exchange"><span class="t-lines"><span>exchange</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/forward.html" title="cpp/utility/forward"><span class="t-lines"><span>forward</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/move.html" title="cpp/utility/move"><span class="t-lines"><span>move</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/move_if_noexcept.html" title="cpp/utility/move if noexcept"><span class="t-lines"><span>move_if_noexcept</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 初等字符串转换</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/to_chars.html" title="cpp/utility/to chars"><span class="t-lines"><span>to_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/from_chars.html" title="cpp/utility/from chars"><span class="t-lines"><span>from_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/chars_format.html" title="cpp/utility/chars format"><span class="t-lines"><span>chars_format</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 类型运算</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/declval.html" title="cpp/utility/declval"><span class="t-lines"><span>declval</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/as_const.html" title="cpp/utility/as const"><span class="t-lines"><span>as_const</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../utility/launder.html" title="cpp/utility/launder"><span class="t-lines"><span>launder</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../chrono.html" title="cpp/chrono">日期和时间工具</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>duration</span></span></strong></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="time_point.html" title="cpp/chrono/time point"><span class="t-lines"><span>time_point</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="time_of_day.html" title="cpp/chrono/time of day"><span class="t-lines"><span>time_of_day</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="clock_time_conversion.html" title="cpp/chrono/clock time conversion"><span class="t-lines"><span>clock_time_conversion</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="clock_cast.html" title="cpp/chrono/clock cast"><span class="t-lines"><span>clock_cast</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 时钟</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="system_clock.html" title="cpp/chrono/system clock"><span class="t-lines"><span>system_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="steady_clock.html" title="cpp/chrono/steady clock"><span class="t-lines"><span>steady_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="high_resolution_clock.html" title="cpp/chrono/high resolution clock"><span class="t-lines"><span>high_resolution_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="is_clock.html" title="cpp/chrono/is clock"><span class="t-lines"><span>is_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5">                                             </td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utc_clock.html" title="cpp/chrono/utc clock"><span class="t-lines"><span>utc_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="tai_clock.html" title="cpp/chrono/tai clock"><span class="t-lines"><span>tai_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="gps_clock.html" title="cpp/chrono/gps clock"><span class="t-lines"><span>gps_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="file_clock.html" title="cpp/chrono/file clock"><span class="t-lines"><span>file_clock</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="local_t.html" title="cpp/chrono/local t"><span class="t-lines"><span>local_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 日历</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="day.html" title="cpp/chrono/day"><span class="t-lines"><span>day</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="month.html" title="cpp/chrono/month"><span class="t-lines"><span>month</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="year.html" title="cpp/chrono/year"><span class="t-lines"><span>year</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="weekday.html" title="cpp/chrono/weekday"><span class="t-lines"><span>weekday</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_slash.html" title="cpp/chrono/operator slash"><span class="t-lines"><span>operator/</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="year_month_day.html" title="cpp/chrono/year month day"><span class="t-lines"><span>year_month_day</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="year_month_day_last.html" title="cpp/chrono/year month day last"><span class="t-lines"><span>year_month_day_last</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="year_month_weekday.html" title="cpp/chrono/year month weekday"><span class="t-lines"><span>year_month_weekday</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="year_month_weekday_last.html" title="cpp/chrono/year month weekday last"><span class="t-lines"><span>year_month_weekday_last</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="weekday_indexed.html" title="cpp/chrono/weekday indexed"><span class="t-lines"><span>weekday_indexed</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="weekday_last.html" title="cpp/chrono/weekday last"><span class="t-lines"><span>weekday_last</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="month_day.html" title="cpp/chrono/month day"><span class="t-lines"><span>month_day</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="month_day_last.html" title="cpp/chrono/month day last"><span class="t-lines"><span>month_day_last</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="month_weekday.html" title="cpp/chrono/month weekday"><span class="t-lines"><span>month_weekday</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="month_weekday_last.html" title="cpp/chrono/month weekday last"><span class="t-lines"><span>month_weekday_last</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="year_month.html" title="cpp/chrono/year month"><span class="t-lines"><span>year_month</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 时区</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="tzdb.html" title="cpp/chrono/tzdb"><span class="t-lines"><span>tzdb</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="tzdb_list.html" title="cpp/chrono/tzdb list"><span class="t-lines"><span>tzdb_list</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="tzdb_functions.html" title="cpp/chrono/tzdb functions"><span class="t-lines"><span>get_tzdb</span><span>get_tzdb_list</span><span>reload_tzdb</span><span>remote_version</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="time_zone.html" title="cpp/chrono/time zone"><span class="t-lines"><span>time_zone</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="locate_zone.html" title="cpp/chrono/locate zone"><span class="t-lines"><span>locate_zone</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="current_zone.html" title="cpp/chrono/current zone"><span class="t-lines"><span>current_zone</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="zoned_time.html" title="cpp/chrono/zoned time"><span class="t-lines"><span>zoned_time</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="link.html" title="cpp/chrono/link"><span class="t-lines"><span>link</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="leap.html" title="cpp/chrono/leap"><span class="t-lines"><span>leap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="c.html" title="cpp/chrono/c"> C 风格日期和时间</a></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><strong class="selflink"><tt>std::chrono::duration</tt></strong><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 成员函数</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/duration.html" title="cpp/chrono/duration/duration"><span class="t-lines"><span>duration::duration</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator%3D.html" title="cpp/chrono/duration/operator="><span class="t-lines"><span>duration::operator=</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/count.html" title="cpp/chrono/duration/count"><span class="t-lines"><span>duration::count</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/zero.html" title="cpp/chrono/duration/zero"><span class="t-lines"><span>duration::zero</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/min.html" title="cpp/chrono/duration/min"><span class="t-lines"><span>duration::min</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/max.html" title="cpp/chrono/duration/max"><span class="t-lines"><span>duration::max</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator_arith.html" title="cpp/chrono/duration/operator arith"><span class="t-lines"><span>duration::operator+</span><span>duration::operator-</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator_arith2.html" title="cpp/chrono/duration/operator arith2"><span class="t-lines"><span>duration::operator++</span><span>duration::operator--</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator_arith3.html" title="cpp/chrono/duration/operator arith3"><span class="t-lines"><span>duration::operator+=</span><span>duration::operator-=</span><span>duration::operator*=</span><span>duration::operator/=</span><span>duration::operator%=</span></span></a></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 非成员函数</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator_arith4.html" title="cpp/chrono/duration/operator arith4"><span class="t-lines"><span>operator+</span><span>operator-</span><span>operator*</span><span>operator/</span><span>operator%</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator_cmp.html" title="cpp/chrono/duration/operator cmp"><span class="t-lines"><span>operator==</span><span>operator!=</span><span>operator&lt;</span><span>operator&lt;=</span><span>operator&gt;</span><span>operator&gt;=</span><span>operator&lt;=&gt;</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/operator_ltlt.html" title="cpp/chrono/duration/operator ltlt"><span class="t-lines"><span>operator&lt;&lt;</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/duration_cast.html" title="cpp/chrono/duration/duration cast"><span class="t-lines"><span>duration_cast</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/floor.html" title="cpp/chrono/duration/floor"><span class="t-lines"><span>floor</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/ceil.html" title="cpp/chrono/duration/ceil"><span class="t-lines"><span>ceil</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/round.html" title="cpp/chrono/duration/round"><span class="t-lines"><span>round</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/abs.html" title="cpp/chrono/duration/abs"><span class="t-lines"><span>abs</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator%2522%2522h.html" title='cpp/chrono/operator""h'><span class="t-lines"><span>operator""h</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator%2522%2522min.html" title='cpp/chrono/operator""min'><span class="t-lines"><span>operator""min</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator%2522%2522s.html" title='cpp/chrono/operator""s'><span class="t-lines"><span>operator""s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator%2522%2522ms.html" title='cpp/chrono/operator""ms'><span class="t-lines"><span>operator""ms</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator%2522%2522us.html" title='cpp/chrono/operator""us'><span class="t-lines"><span>operator""us</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator%2522%2522ns.html" title='cpp/chrono/operator""ns'><span class="t-lines"><span>operator""ns</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/from_stream.html" title="cpp/chrono/duration/from stream"><span class="t-lines"><span>from_stream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 辅助类</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/common_type.html" title="cpp/chrono/duration/common type"><span class="t-lines"><span>common_type</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="treat_as_floating_point.html" title="cpp/chrono/treat as floating point"><span class="t-lines"><span>treat_as_floating_point</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration_values.html" title="cpp/chrono/duration values"><span class="t-lines"><span>duration_values</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="duration/formatter.html" title="cpp/chrono/duration/formatter"><span class="t-lines"><span>formatter<span class="t-dsc-small">&lt;std::chrono::duration&gt;</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>定义于头文件 <code><a href="../header/chrono.html" title="cpp/header/chrono">&lt;chrono&gt;</a></code>
 </div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span><br>
<p>    <span class="kw1">class</span> Rep, <br>
    <span class="kw1">class</span> Period <span class="sy1">=</span> <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">1</span><span class="sy1">&gt;</span> <br>
</p>
<span class="sy1">&gt;</span> <span class="kw1">class</span> duration<span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx11">(C++11 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>类模板 <code>std::chrono::duration</code> 表示时间间隔。
</p><p>它由 <code>Rep</code> 类型的计次数和计次周期组成，其中计次周期是一个编译期有理数常量，表示从一个计次到下一个的秒数。
</p><p>存储于 <code>duration</code> 的数据仅有 <code>Rep</code> 类型的计次数。若 <code>Rep</code> 是浮点数，则 <code>duration</code> 能表示小数的计次数。 <code>Period</code> 被包含为时长类型的一部分，且只在不同时长间转换时使用。
</p>
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB.E5.9E.8B">成员类型</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td>  成员类型
</td>
<td>  定义
</td></tr>


<tr class="t-dsc">
<td>  <code>rep</code>
</td>
<td>  <code>Rep</code> ，表示计次数的算术类型
</td></tr>

<tr class="t-dsc">
<td>  <code>period</code>
</td>
<td>  <span class="t-rev-inl t-until-cxx17"><span><code>Period</code></span> <span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span><span class="t-rev-inl t-since-cxx17"><span><code>typename Period::type</code></span> <span><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></span></span> ，表示计次周期的 <span class="t-lc"><a href="../numeric/ratio/ratio.html" title="cpp/numeric/ratio/ratio">std::ratio</a></span> （即每秒的次数）
</td></tr>
</table>
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0">成员函数</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div t-dsc-member-nobold-div"><div><a href="duration/duration.html" title="cpp/chrono/duration/duration"> <span class="t-lines"><span>(构造函数)</span></span></a></div></div>
</td>
<td>  构造新 duration <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator%3D.html" title="cpp/chrono/duration/operator="> <span class="t-lines"><span>operator=</span></span></a></div></div>
</td>
<td>   赋值内容 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/count.html" title="cpp/chrono/duration/count"> <span class="t-lines"><span>count</span></span></a></div></div>
</td>
<td>  返回计次的计数 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/zero.html" title="cpp/chrono/duration/zero"> <span class="t-lines"><span>zero</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[静态]</span></span></span></div></div>
</td>
<td>  返回特殊时长值零 <br> <span class="t-mark">(公开静态成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/min.html" title="cpp/chrono/duration/min"> <span class="t-lines"><span>min</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[静态]</span></span></span></div></div>
</td>
<td>  返回特殊时长值最小值 <br> <span class="t-mark">(公开静态成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/max.html" title="cpp/chrono/duration/max"> <span class="t-lines"><span>max</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[静态]</span></span></span></div></div>
</td>
<td>  返回特殊时长值最大值 <br> <span class="t-mark">(公开静态成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator_arith.html" title="cpp/chrono/duration/operator arith"> <span class="t-lines"><span>operator+</span><span>operator-</span></span></a></div></div>
</td>
<td>  实现一元 + 和一元 - <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator_arith2.html" title="cpp/chrono/duration/operator arith2"> <span class="t-lines"><span>operator++</span><span>operator++<span class="t-dsc-small">(int)</span></span><span>operator--</span><span>operator--<span class="t-dsc-small">(int)</span></span></span></a></div></div>
</td>
<td>  递增或递减滴答计数 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator_arith3.html" title="cpp/chrono/duration/operator arith3"> <span class="t-lines"><span>operator+=</span><span>operator-=</span><span>operator*=</span><span>operator/=</span><span>operator%=</span></span></a></div></div>
</td>
<td>  实现二个时长间的复合赋值 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E9.9D.9E.E6.88.90.E5.91.98.E5.87.BD.E6.95.B0">非成员函数</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator_arith4.html" title="cpp/chrono/duration/operator arith4"> <span class="t-lines"><span>operator+</span><span>operator-</span><span>operator*</span><span>operator/</span><span>operator%</span></span></a></div></div>
</td>
<td>  实现以时长为实参的算术运算 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator_cmp.html" title="cpp/chrono/duration/operator cmp"> <span class="t-lines"><span>operator==</span><span>operator!=</span><span>operator&lt;</span><span>operator&lt;=</span><span>operator&gt;</span><span>operator&gt;=</span><span>operator&lt;=&gt;</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 中移除)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 中移除)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 中移除)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 中移除)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 中移除)</span></span><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  比较两个时长  <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/duration_cast.html" title="cpp/chrono/duration/duration cast"> <span class="t-lines"><span>duration_cast</span></span></a></div></div>
</td>
<td>   转换时长到另一个拥有不同嘀嗒间隔的时长 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/floor.html" title="cpp/chrono/duration/floor"> <span class="t-lines"><span>floor<span class="t-dsc-small">(std::chrono::duration)</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>   以向下取整的方式，将一个时长转换为另一个时长  <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/ceil.html" title="cpp/chrono/duration/ceil"> <span class="t-lines"><span>ceil<span class="t-dsc-small">(std::chrono::duration)</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>   以向上取整的方式，将一个时长转换为另一个时长  <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/round.html" title="cpp/chrono/duration/round"> <span class="t-lines"><span>round<span class="t-dsc-small">(std::chrono::duration)</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>   转换时长到另一个时长，就近取整，偶数优先 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/abs.html" title="cpp/chrono/duration/abs"> <span class="t-lines"><span>abs<span class="t-dsc-small">(std::chrono::duration)</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>   获取时长的绝对值  <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/operator_ltlt.html" title="cpp/chrono/duration/operator ltlt"> <span class="t-lines"><span>operator&lt;&lt;</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  进行 <code>duration</code> 上的流输出 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/from_stream.html" title="cpp/chrono/duration/from stream"> <span class="t-lines"><span>from_stream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  按照提供的格式，从流分析 <code>duration</code> <br> <span class="t-mark">(函数模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E8.BE.85.E5.8A.A9.E7.B1.BB.E5.9E.8B">辅助类型</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td>  类型
</td>
<td>  定义
</td></tr>


<tr class="t-dsc">
<td>  <span class="t-lc"><strong class="selflink">std::chrono::nanoseconds</strong></span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 64 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1519">std::<span class="me2">nano</span></span></a><span class="sy1">&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc"><strong class="selflink">std::chrono::microseconds</strong></span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 55 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1520">std::<span class="me2">micro</span></span></a><span class="sy1">&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc"><strong class="selflink">std::chrono::milliseconds</strong></span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 45 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1521">std::<span class="me2">milli</span></span></a><span class="sy1">&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc"><strong class="selflink">std::chrono::seconds</strong></span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 35 位的有符号整数类型*/</span><span class="sy1">&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc"><strong class="selflink">std::chrono::minutes</strong></span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 29 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">60</span><span class="sy1">&gt;&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc"><strong class="selflink">std::chrono::hours</strong></span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 23 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">3600</span><span class="sy1">&gt;&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc">std::chrono::days</span> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 25 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">86400</span><span class="sy1">&gt;&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc">std::chrono::weeks</span> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 22 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">604800</span><span class="sy1">&gt;&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc">std::chrono::months</span> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 20 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">2629746</span><span class="sy1">&gt;&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <span class="t-lc">std::chrono::years</span> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">duration<span class="sy1">&lt;</span><span class="coMULTI">/*至少 17 位的有符号整数类型*/</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">31556952</span><span class="sy1">&gt;&gt;</span></span></span>
</td></tr>
</table>
<p>注意：到 <code>hours</code> 为止的每个预定义时长类型至少涵盖 ±292 年的范围。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<p>每个预定义时长类型 <code>days</code> 、 <code>weeks</code> 、 <code>months</code> 和 <code>years</code> 至少涵盖 ±40000 年范围。 <code>years</code> 等于 365.2425 <code>days</code> （格里高利年的平均长度）。 <code>months</code> 等于 30.436875 <code>days</code> （ <code>years</code> 的准确的 1/12 ）。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table>
<h3><span class="mw-headline" id=".E8.BE.85.E5.8A.A9.E7.B1.BB">辅助类</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/common_type.html" title="cpp/chrono/duration/common type"> <span class="t-lines"><span>std::common_type<span class="t-dsc-small">&lt;std::chrono::duration&gt;</span></span></span></a></div></div>
</td>
<td>   特化 <span class="t-lc"><a href="../types/common_type.html" title="cpp/types/common type">std::common_type</a></span> 特征 <br> <span class="t-mark">(类模板特化)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="treat_as_floating_point.html" title="cpp/chrono/treat as floating point"> <span class="t-lines"><span>treat_as_floating_point</span></span></a></div></div>
</td>
<td>   指示时长可转换为拥有不同计次的时长 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration_values.html" title="cpp/chrono/duration values"> <span class="t-lines"><span>duration_values</span></span></a></div></div>
</td>
<td>   构造给定类型计次的零、最小及最大值 <br> <span class="t-mark">(类模板)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="duration/formatter.html" title="cpp/chrono/duration/formatter"> <span class="t-lines"><span>std::formatter<span class="t-dsc-small">&lt;std::chrono::duration&gt;</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   <span class="t-lc">std::formatter</span> 的特化，按提供的格式格式化 <code>duration</code>  <br> <span class="t-mark">(类模板特化)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E5.AD.97.E9.9D.A2.E9.87.8F">字面量</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于内联命名空间 <code>std::literals::chrono_literals</code></div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator%2522%2522h.html" title='cpp/chrono/operator""h'> <span class="t-lines"><span>operator""h</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  表示小时的 <span class="t-lc"><strong class="selflink">std::chrono::duration</strong></span> 字面量 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator%2522%2522min.html" title='cpp/chrono/operator""min'> <span class="t-lines"><span>operator""min</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  表示分钟的 <span class="t-lc"><strong class="selflink">std::chrono::duration</strong></span> 字面量 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator%2522%2522s.html" title='cpp/chrono/operator""s'> <span class="t-lines"><span>operator""s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  表示秒的 <span class="t-lc"><strong class="selflink">std::chrono::duration</strong></span> 字面量 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator%2522%2522ms.html" title='cpp/chrono/operator""ms'> <span class="t-lines"><span>operator""ms</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  表示毫秒的 <span class="t-lc"><strong class="selflink">std::chrono::duration</strong></span> 字面量 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator%2522%2522us.html" title='cpp/chrono/operator""us'> <span class="t-lines"><span>operator""us</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  表示微秒的 <span class="t-lc"><strong class="selflink">std::chrono::duration</strong></span> 字面量 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator%2522%2522ns.html" title='cpp/chrono/operator""ns'> <span class="t-lines"><span>operator""ns</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  表示纳秒的 <span class="t-lc"><strong class="selflink">std::chrono::duration</strong></span> 字面量 <br> <span class="t-mark">(函数)</span> </td></tr>
</table>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<p>注意：字面量后缀 <code>d</code> 和 <code>y</code> 不指代 <code>days</code> 和 <code>years</code> ，而是分别指代 <a href="day.html" title="cpp/chrono/day"><tt>day</tt></a> 和 <a href="year.html" title="cpp/chrono/year"><tt>year</tt></a> 。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<div class="t-example"><p>此示例演示如何定义几种自定义时长类型及在类型间转换：</p><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;iostream&gt;</span>
<span class="co2">#include &lt;chrono&gt;</span>
 
<span class="kw4">constexpr</span> <span class="kw4">auto</span> year <span class="sy1">=</span> 31556952ll<span class="sy4">;</span> <span class="co1">// 格里高利历年的平均秒数</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    <span class="kw1">using</span> shakes <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">duration</span><span class="sy1">&lt;</span><span class="kw4">int</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">1</span>, <span class="nu0">100000000</span><span class="sy1">&gt;&gt;</span><span class="sy4">;</span>
    <span class="kw1">using</span> jiffies <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">duration</span><span class="sy1">&lt;</span><span class="kw4">int</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1522">std::<span class="me2">centi</span></span></a><span class="sy1">&gt;</span><span class="sy4">;</span>
    <span class="kw1">using</span> microfortnights <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">duration</span><span class="sy1">&lt;</span><span class="kw4">float</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">14</span><span class="sy2">*</span><span class="nu0">24</span><span class="sy2">*</span><span class="nu0">60</span><span class="sy2">*</span><span class="nu0">60</span>, <span class="nu0">1000000</span><span class="sy1">&gt;&gt;</span><span class="sy4">;</span>
    <span class="kw1">using</span> nanocenturies <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">duration</span><span class="sy1">&lt;</span><span class="kw4">float</span>, <a href="../numeric/ratio/ratio.html"><span class="kw1515">std::<span class="me2">ratio</span></span></a><span class="sy1">&lt;</span><span class="nu0">100</span><span class="sy2">*</span>year, <span class="nu0">1000000000</span><span class="sy1">&gt;&gt;</span><span class="sy4">;</span>
 
    std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">seconds</span> sec<span class="br0">(</span><span class="nu0">1</span><span class="br0">)</span><span class="sy4">;</span>
 
    <a href="../io/cout.html"><span class="kw1751">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"1 second is:<span class="es1">\n</span>"</span><span class="sy4">;</span>
 
    <span class="co1">// 无精度损失的整数尺度转换：无转型</span>
    <a href="../io/cout.html"><span class="kw1751">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">microseconds</span><span class="br0">(</span>sec<span class="br0">)</span>.<span class="me1">count</span><span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">" microseconds<span class="es1">\n</span>"</span>
              <span class="sy1">&lt;&lt;</span> shakes<span class="br0">(</span>sec<span class="br0">)</span>.<span class="me1">count</span><span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">" shakes<span class="es1">\n</span>"</span>
              <span class="sy1">&lt;&lt;</span> jiffies<span class="br0">(</span>sec<span class="br0">)</span>.<span class="me1">count</span><span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">" jiffies<span class="es1">\n</span>"</span><span class="sy4">;</span>
 
    <span class="co1">// 有精度损失的整数尺度转换：需要转型</span>
    <a href="../io/cout.html"><span class="kw1751">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <a href="duration/duration_cast.html"><span class="kw993">std::<span class="me2">chrono</span><span class="sy4">::</span><span class="me2">duration_cast</span></span></a><span class="sy1">&lt;</span>std<span class="sy4">::</span><span class="me2">chrono</span><span class="sy4">::</span><span class="me2">minutes</span><span class="sy1">&gt;</span><span class="br0">(</span>sec<span class="br0">)</span>.<span class="me1">count</span><span class="br0">(</span><span class="br0">)</span>
              <span class="sy1">&lt;&lt;</span> <span class="st0">" minutes<span class="es1">\n</span>"</span><span class="sy4">;</span>
 
    <span class="co1">// 浮点尺度转换：无转型</span>
    <a href="../io/cout.html"><span class="kw1751">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> microfortnights<span class="br0">(</span>sec<span class="br0">)</span>.<span class="me1">count</span><span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">" microfortnights<span class="es1">\n</span>"</span>
              <span class="sy1">&lt;&lt;</span> nanocenturies<span class="br0">(</span>sec<span class="br0">)</span>.<span class="me1">count</span><span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">" nanocenturies<span class="es1">\n</span>"</span><span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">1 second is:
1000000 microseconds
100000000 shakes
100 jiffies
0 minutes
0.82672 microfortnights
0.316887 nanocenturies</pre></div></div> 
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 13913/1000000
Preprocessor generated node count: 16463/1000000
Post‐expand include size: 440128/2097152 bytes
Template argument size: 91871/2097152 bytes
Highest expansion depth: 22/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:1533-0!*!0!!zh!*!zh!* and timestamp 20200203144545 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/chrono/duration&amp;oldid=64123">https://zh.cppreference.com/mwiki/index.php?title=cpp/chrono/duration&amp;oldid=64123</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/chrono/duration">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2020年1月28日 (星期二) 03:39。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过41,979次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 2.026 secs. -->
	</body>
<!-- Cached 20200203144545 -->
</html>